package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Getter@Setter
public class Product extends BaseDomain{

    public static final int FOOD = 1;//食品
    public static final int DAILY = 2;//生活用品
    public static final int ELECTRONICS = 3;//电子产品
    public static final int CLOTHES = 4;//衣服

    //商品名称
    private String productName;

    //价格
    private Integer price;

    //图片
    private String pics;

    //主图
    private String coverUrl;

    //分类信息
    private Integer status = -1;

    //简单介绍
    private String introduce;

    //商品详情
    private ProductContent content;

    //创建时间
    @JsonFormat(pattern = "y-m-d",timezone = "GMT-8")
    @DateTimeFormat(pattern = "y-m-d")
    private Date createTime;

    public String getJson(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("productName",productName);
        map.put("price",price);
        map.put("pics",pics);
        map.put("coverUrl",coverUrl);
        map.put("status",status);
        map.put("introduce",introduce);
        return JSONUtil.toJSONString(map);
    }

}